Skip to content

fix: export Resource attributes for metrics and traces - #63

Merged
inge4pres merged 1 commit into
open-telemetry:mainfrom
bachgarash:fix/export-resource-attributes
Aug 17, 2026
Merged

fix: export Resource attributes for metrics and traces#63
inge4pres merged 1 commit into
open-telemetry:mainfrom
bachgarash:fix/export-resource-attributes

Conversation

@bachgarash

@bachgarash bachgarash commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

The SDK parsed OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES and built a resource on both TracerProvider and MeterProvider, but neither the trace nor the metrics OTLP exporter attached it to the exported payload. Spans and metrics reached the collector with no resource, so backends could not identify the emitting service, traces appears in Jaeger under missing-service-name.

Carry the provider's resource on the exported data the way logs already do.

Also, extract resourceToProtobuf in the metrics exporter so the conversion can be tested without performing an HTTP export, matching the existing separation between spansToOTLPRequest and exportSpans on the trace side.

Fixes #62

after the fix

Screenshot From 2026-08-12 22-05-40

The SDK parsed OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES and built a
resource on both TracerProvider and MeterProvider, but neither the trace nor
the metrics OTLP exporter attached it to the exported payload. Spans and
metrics reached the collector with no resource, so backends could not
identify the emitting service: traces appears in Jaeger under
missing-service-name and target_info could not be produced for metrics.

Carry the provider's resource on the exported data the way logs already
do.

Also, extract resourceToProtobuf in the metrics exporter so the conversion can be
tested without performing an HTTP export, matching the existing separation
between spansToOTLPRequest and exportSpans on the trace side.

Fixes open-telemetry#62
@bachgarash
bachgarash requested a review from a team as a code owner August 12, 2026 19:04

@agagniere agagniere left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks !

@inge4pres inge4pres left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the

Comment on lines +219 to +225
if (resource) |attrs| {
try kvs.ensureTotalCapacityPrecise(allocator, attrs.len);
for (attrs) |attr| {
kvs.appendAssumeCapacity(try attributeToProtobuf(allocator, attr));
}
}
return kvs;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍🏼

@inge4pres
inge4pres merged commit a5e2476 into open-telemetry:main Aug 17, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Traces and metrics are exported without a Resource, so service.name is lost

3 participants